package JZ31_整数中1出现的次数_从1到n整数中1出现的次数;

public class Solution {
    public int NumberOf1Between1AndN_Solution(int n) {
        int count = 0;
        for (int i = 0; i < n; i++){
            count += NumberOf1(i);
        }
        return count;
    }

    private int NumberOf1(int n) {
        int count = 0;
        while (n != 0){
            if (n % 10 == 1){
                count++;
            }
            n = n / 10;
        }
        return count;
    }
}